<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Annex: Alternatives</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.ScopeExit 1.1.0">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.ScopeExit 1.1.0">
<link rel="prev" href="tutorial.html" title="Tutorial">
<link rel="next" href="no_variadic_macros.html" title="Annex: No Variadic Macros">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="tutorial.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="no_variadic_macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="scope_exit.alternatives"></a><a class="link" href="alternatives.html" title="Annex: Alternatives">Annex: Alternatives</a>
</h2></div></div></div>
<p>
      This section presents some alternative and related work to <a class="link" href="../index.html" title="Chapter&#160;1.&#160;Boost.ScopeExit 1.1.0">Boost.ScopeExit</a>.
    </p>
<h4>
<a name="scope_exit.alternatives.h0"></a>
      <span class="phrase"><a name="scope_exit.alternatives.try_catch"></a></span><a class="link" href="alternatives.html#scope_exit.alternatives.try_catch">Try-Catch</a>
    </h4>
<p>
      This is an example of using a badly designed <code class="computeroutput"><span class="identifier">file</span></code>
      class. An instance of <code class="computeroutput"><span class="identifier">file</span></code>
      does not close the file in its destructor, a programmer is expected to call
      the <code class="computeroutput"><span class="identifier">close</span></code> member function explicitly.
      For example (see also <a href="../../../example/try_catch.cpp" target="_top"><code class="literal">try_catch.cpp</code></a>):
    </p>
<p>
</p>
<pre class="programlisting"><span class="identifier">file</span> <span class="identifier">passwd</span><span class="special">;</span>
<span class="keyword">try</span> <span class="special">{</span>
    <span class="identifier">passwd</span><span class="special">.</span><span class="identifier">open</span><span class="special">(</span><span class="string">"/etc/passwd"</span><span class="special">);</span>
    <span class="comment">// ...</span>
    <span class="identifier">passwd</span><span class="special">.</span><span class="identifier">close</span><span class="special">();</span>
<span class="special">}</span> <span class="keyword">catch</span><span class="special">(...)</span> <span class="special">{</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">clog</span> <span class="special">&lt;&lt;</span> <span class="string">"could not get user info"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="keyword">if</span><span class="special">(</span><span class="identifier">passwd</span><span class="special">.</span><span class="identifier">is_open</span><span class="special">())</span> <span class="identifier">passwd</span><span class="special">.</span><span class="identifier">close</span><span class="special">();</span>
    <span class="keyword">throw</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
    </p>
<p>
      Note the following issues with this approach:
    </p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
          The <code class="computeroutput"><span class="identifier">passwd</span></code> object is defined
          outside of the <code class="computeroutput"><span class="keyword">try</span></code> block because
          this object is required inside the <code class="computeroutput"><span class="keyword">catch</span></code>
          block to close the file.
        </li>
<li class="listitem">
          The <code class="computeroutput"><span class="identifier">passwd</span></code> object is not
          fully constructed until after the <code class="computeroutput"><span class="identifier">open</span></code>
          member function returns.
        </li>
<li class="listitem">
          If opening throws, the <code class="computeroutput"><span class="identifier">passwd</span><span class="special">.</span><span class="identifier">close</span><span class="special">()</span></code> should not be called, hence the call
          to <code class="computeroutput"><span class="identifier">passwd</span><span class="special">.</span><span class="identifier">is_open</span><span class="special">()</span></code>.
        </li>
</ol></div>
<p>
      The <a class="link" href="../index.html" title="Chapter&#160;1.&#160;Boost.ScopeExit 1.1.0">Boost.ScopeExit</a> approach does not have
      any of these issues. For example (see also <a href="../../../example/try_catch.cpp" target="_top"><code class="literal">try_catch.cpp</code></a>):
    </p>
<p>
</p>
<pre class="programlisting"><span class="keyword">try</span> <span class="special">{</span>
    <span class="identifier">file</span> <span class="identifier">passwd</span><span class="special">(</span><span class="string">"/etc/passwd"</span><span class="special">);</span>
    <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(&amp;</span><span class="identifier">passwd</span><span class="special">)</span> <span class="special">{</span>
        <span class="identifier">passwd</span><span class="special">.</span><span class="identifier">close</span><span class="special">();</span>
    <span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>
<span class="special">}</span> <span class="keyword">catch</span><span class="special">(...)</span> <span class="special">{</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">clog</span> <span class="special">&lt;&lt;</span> <span class="string">"could not get user info"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="keyword">throw</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
    </p>
<h4>
<a name="scope_exit.alternatives.h1"></a>
      <span class="phrase"><a name="scope_exit.alternatives.raii"></a></span><a class="link" href="alternatives.html#scope_exit.alternatives.raii">RAII</a>
    </h4>
<p>
      <a href="http://www.research.att.com/~bs/glossary.html#Gresource-acquisition-is-initialization" target="_top">RAII</a>
      is absolutely perfect for the <code class="computeroutput"><span class="identifier">file</span></code>
      class introduced above. Use of a properly designed <code class="computeroutput"><span class="identifier">file</span></code>
      class would look like:
    </p>
<pre class="programlisting"><span class="keyword">try</span> <span class="special">{</span>
    <span class="identifier">file</span> <span class="identifier">passwd</span><span class="special">(</span><span class="string">"/etc/passwd"</span><span class="special">);</span>
    <span class="comment">// ...</span>
<span class="special">}</span> <span class="keyword">catch</span><span class="special">(...)</span> <span class="special">{</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">clog</span> <span class="special">&lt;&lt;</span> <span class="string">"could not get user info"</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="keyword">throw</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
      However, using <a href="http://www.research.att.com/~bs/glossary.html#Gresource-acquisition-is-initialization" target="_top">RAII</a>
      to build up a <a href="http://www.research.att.com/~bs/glossary.html#Gstrong-guarantee" target="_top">strong
      guarantee</a> could introduce a lot of non-reusable <a href="http://www.research.att.com/~bs/glossary.html#Gresource-acquisition-is-initialization" target="_top">RAII</a>
      types. For example:
    </p>
<pre class="programlisting"><span class="identifier">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span>
<span class="identifier">pop_back_if_not_commit</span> <span class="identifier">pop_back_if_not_commit_guard</span><span class="special">(</span><span class="identifier">commit</span><span class="special">,</span> <span class="identifier">persons_</span><span class="special">);</span>
</pre>
<p>
      The <code class="computeroutput"><span class="identifier">pop_back_if_not_commit</span></code>
      class is either defined out of the scope or as a local class:
    </p>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">pop_back_if_not_commit</span> <span class="special">{</span>
    <span class="keyword">bool</span> <span class="identifier">commit_</span><span class="special">;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">person</span><span class="special">&gt;&amp;</span> <span class="identifier">vec_</span><span class="special">;</span>
    <span class="comment">// ...</span>
    <span class="special">~</span><span class="identifier">pop_back_if_not_commit</span><span class="special">()</span> <span class="special">{</span>
        <span class="keyword">if</span><span class="special">(!</span><span class="identifier">commit_</span><span class="special">)</span> <span class="identifier">vec_</span><span class="special">.</span><span class="identifier">pop_back</span><span class="special">();</span>
    <span class="special">}</span>
<span class="special">};</span>
</pre>
<p>
      In some cases <a href="http://www.research.att.com/~bs/glossary.html#Gstrong-guarantee" target="_top">strong
      guarantee</a> can be accomplished with standard utilities:
    </p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">auto_ptr</span><span class="special">&lt;</span><span class="identifier">Person</span><span class="special">&gt;</span> <span class="identifier">superman_ptr</span><span class="special">(</span><span class="keyword">new</span> <span class="identifier">superman</span><span class="special">());</span>
<span class="identifier">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">superman_ptr</span><span class="special">.</span><span class="identifier">get</span><span class="special">());</span>
<span class="identifier">superman_ptr</span><span class="special">.</span><span class="identifier">release</span><span class="special">();</span> <span class="comment">// persons_ successfully took ownership</span>
</pre>
<p>
      Or with specialized containers such as <a href="http://www.boost.org/libs/ptr_container" target="_top">Boost.PointerContainer</a>
      or <a href="http://www.boost.org/libs/multi_index" target="_top">Boost.Multi-Index</a>.
    </p>
<h4>
<a name="scope_exit.alternatives.h2"></a>
      <span class="phrase"><a name="scope_exit.alternatives.scope_guards"></a></span><a class="link" href="alternatives.html#scope_exit.alternatives.scope_guards">Scope
      Guards</a>
    </h4>
<p>
      Imagine that a new currency rate is introduced before performing a transaction
      (see also []):
    </p>
<p>
</p>
<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">currency</span><span class="special">(</span><span class="string">"EUR"</span><span class="special">);</span>
<span class="keyword">double</span> <span class="identifier">rate</span> <span class="special">=</span> <span class="number">1.3326</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">rates</span><span class="special">;</span>
<span class="keyword">bool</span> <span class="identifier">currency_rate_inserted</span> <span class="special">=</span>
        <span class="identifier">rates</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">currency</span><span class="special">,</span> <span class="identifier">rate</span><span class="special">)).</span><span class="identifier">second</span><span class="special">;</span>
<span class="comment">// Transaction...</span>
</pre>
<p>
    </p>
<p>
      If the transaction does not complete, the currency must be erased from <code class="computeroutput"><span class="identifier">rates</span></code>. This can be done with <a href="http://www.ddj.com/dept/cpp/184403758" target="_top">ScopeGuard</a>
      and <a href="http://www.boost.org/libs/lambda" target="_top">Boost.Lambda</a> (or
      <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a>):
    </p>
<pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">lambda</span><span class="special">;</span>

<span class="identifier">ON_BLOCK_EXIT</span><span class="special">(</span>
    <span class="identifier">if_</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">_1</span><span class="special">)</span> <span class="special">[</span>
        <span class="identifier">bind</span><span class="special">(</span>
            <span class="keyword">static_cast</span><span class="special">&lt;</span>
                <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">double</span><span class="special">&gt;::</span><span class="identifier">size_type</span>
                <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">double</span><span class="special">&gt;::*)(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;)</span>
            <span class="special">&gt;(&amp;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">double</span><span class="special">&gt;::</span><span class="identifier">erase</span><span class="special">)</span>
          <span class="special">,</span> <span class="special">&amp;</span><span class="identifier">rates</span>
          <span class="special">,</span> <span class="identifier">currency</span>
        <span class="special">)</span>
    <span class="special">]</span>
  <span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">cref</span><span class="special">(</span><span class="identifier">commit</span><span class="special">)</span>
  <span class="special">);</span>

<span class="comment">// ...</span>

<span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
</pre>
<p>
      Note the following issues with this approach:
    </p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
          <a href="http://www.boost.org/libs/lambda" target="_top">Boost.Lambda</a> expressions
          are hard to write correctly (e.g., overloaded functions must be explicitly
          casted, as demonstrated in the example above).
        </li>
<li class="listitem">
          The condition in the <code class="computeroutput"><span class="identifier">if_</span></code>
          expression refers to <code class="computeroutput"><span class="identifier">commit</span></code>
          variable indirectly through the <code class="computeroutput"><span class="identifier">_1</span></code>
          placeholder reducing readability.
        </li>
<li class="listitem">
          Setting a breakpoint inside <code class="computeroutput"><span class="identifier">if_</span><span class="special">[...]</span></code> requires in-depth knowledge of <a href="http://www.boost.org/libs/lambda" target="_top">Boost.Lambda</a> and debugging
          techniques.
        </li>
</ol></div>
<p>
      This code will look much better with C++11 lambdas:
    </p>
<pre class="programlisting"><span class="identifier">ON_BLOCK_EXIT</span><span class="special">(</span>
    <span class="special">[</span><span class="identifier">currency_rate_inserted</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">commit</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">rates</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">currency</span><span class="special">]()</span> <span class="special">{</span>
        <span class="keyword">if</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">commit</span><span class="special">)</span> <span class="identifier">rates</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="identifier">currency</span><span class="special">);</span>
    <span class="special">}</span>
<span class="special">);</span>

<span class="comment">// ...</span>

<span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
</pre>
<p>
      With <a class="link" href="../index.html" title="Chapter&#160;1.&#160;Boost.ScopeExit 1.1.0">Boost.ScopeExit</a> we can simply do the
      following (see also <a href="../../../example/scope_guard.cpp" target="_top"><code class="literal">scope_guard.cpp</code></a>):
    </p>
<p>
</p>
<pre class="programlisting"><span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">commit</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">rates</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">currency</span><span class="special">)</span> <span class="special">{</span>
    <span class="keyword">if</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">commit</span><span class="special">)</span> <span class="identifier">rates</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="identifier">currency</span><span class="special">);</span>
<span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>

<span class="comment">// ...</span>

<span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
</pre>
<p>
    </p>
<h4>
<a name="scope_exit.alternatives.h3"></a>
      <span class="phrase"><a name="scope_exit.alternatives.the_d_programming_language"></a></span><a class="link" href="alternatives.html#scope_exit.alternatives.the_d_programming_language">The
      D Programming Language</a>
    </h4>
<p>
      <a class="link" href="../index.html" title="Chapter&#160;1.&#160;Boost.ScopeExit 1.1.0">Boost.ScopeExit</a> is similar to <a href="http://www.digitalmars.com/d/2.0/statement.html#ScopeGuardStatement" target="_top">scope(exit)</a>
      feature built into the <a href="http://www.digitalmars.com/d/index.html" target="_top">D</a>
      programming language.
    </p>
<p>
      A curious reader may notice that the library does not implement <code class="computeroutput"><span class="identifier">scope</span><span class="special">(</span><span class="identifier">success</span><span class="special">)</span></code> and <code class="computeroutput"><span class="identifier">scope</span><span class="special">(</span><span class="identifier">failure</span><span class="special">)</span></code> of the <a href="http://www.digitalmars.com/d/index.html" target="_top">D</a>
      language. Unfortunately, these are not possible in C++ because failure or success
      conditions cannot be determined by calling <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">uncaught_exception</span></code>
      (see <a href="http://www.gotw.ca/gotw/047.htm" target="_top">Guru of the Week #47</a>
      for details about <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">uncaught_exception</span></code> and if it has any good
      use at all). However, this is not a big problem because these two <a href="http://www.digitalmars.com/d/index.html" target="_top">D</a>'s
      constructs can be expressed in terms of <a href="http://www.digitalmars.com/d/2.0/statement.html#ScopeGuardStatement" target="_top">scope(exit)</a>
      and a <code class="computeroutput"><span class="keyword">bool</span> <span class="identifier">commit</span></code>
      variable (similarly to some examples presented in the <a class="link" href="tutorial.html" title="Tutorial">Tutorial</a>
      section).
    </p>
<h4>
<a name="scope_exit.alternatives.h4"></a>
      <span class="phrase"><a name="scope_exit.alternatives.c__11_lambdas"></a></span><a class="link" href="alternatives.html#scope_exit.alternatives.c__11_lambdas">C++11
      Lambdas</a>
    </h4>
<p>
      Using C++11 lambdas, it is relatively easy to implement the <a class="link" href="../index.html" title="Chapter&#160;1.&#160;Boost.ScopeExit 1.1.0">Boost.ScopeExit</a>
      construct. For example (see also <a href="../../../example/world_cxx11_lambda.cpp" target="_top"><code class="literal">world_cxx11_lambda.cpp</code></a>):
    </p>
<p>
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">functional</span><span class="special">&gt;</span>

<span class="keyword">struct</span> <span class="identifier">scope_exit</span> <span class="special">{</span>
    <span class="identifier">scope_exit</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">void</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)&gt;</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">f_</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span> <span class="special">{}</span>
    <span class="special">~</span><span class="identifier">scope_exit</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">f_</span><span class="special">();</span> <span class="special">}</span>
<span class="keyword">private</span><span class="special">:</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">void</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)&gt;</span> <span class="identifier">f_</span><span class="special">;</span>
<span class="special">};</span>

<span class="keyword">void</span> <span class="identifier">world</span><span class="special">::</span><span class="identifier">add_person</span><span class="special">(</span><span class="identifier">person</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">a_person</span><span class="special">)</span> <span class="special">{</span>
    <span class="keyword">bool</span> <span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">;</span>

    <span class="identifier">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span>
    <span class="identifier">scope_exit</span> <span class="identifier">on_exit1</span><span class="special">([&amp;</span><span class="identifier">commit</span><span class="special">,</span> <span class="keyword">this</span><span class="special">](</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Use C++11 lambda.</span>
        <span class="keyword">if</span><span class="special">(!</span><span class="identifier">commit</span><span class="special">)</span> <span class="identifier">persons_</span><span class="special">.</span><span class="identifier">pop_back</span><span class="special">();</span> <span class="comment">// `persons_` via captured `this`.</span>
    <span class="special">});</span>

    <span class="comment">// ...</span>

    <span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
    </p>
<p>
      However, this library allows to program the <a class="link" href="../index.html" title="Chapter&#160;1.&#160;Boost.ScopeExit 1.1.0">Boost.ScopeExit</a>
      construct in a way that is portable between C++03 and C++11 compilers.
    </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2012 Alexander Nasonov, Lorenzo Caminiti<p>
        Distributed under the Boost Software License, Version 1.0 (see accompanying
        file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="tutorial.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="no_variadic_macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
